<?php

	// +----------------------------------------------------------------------
	// | 系统版本信息
	// +----------------------------------------------------------------------
	// | Copyright (c) 2015-2024 http://www.yicmf.com, All rights reserved.
	// +----------------------------------------------------------------------
	// | Author: 微尘 <yicmf@qq.com>
	// +----------------------------------------------------------------------

	namespace app\model\admin;

	use think\facade\Config;

	class Version extends Common
	{
		protected $dateFormat = 'Y-m-d';

		/**
		 * 获取当前的版本号
		 */
		public function getCurrentVersion()
		{
			return $this->get([
				'version' => Config::get('yicmf.version')
			]);
		}

		/**
		 * 获取要升级的版本.
		 * @return array
		 */
		public function getNextVersion()
		{
			return $this->order('build asc')->where('build', '>', Config::get('yicmf.build'))->find() ?: false;
		}

		/**
		 * 写入修改
		 * @param $data
		 */
		public static function onBeforeInsert($data)
		{
			$data['status'] = 1;
			$data['update_status'] = 1;
		}

	}
